Impact of azure deployment slot swap on application configuration settings
In our previous video, we discussed deployment slots, how to create and their use. In this video we will discuss what happens to application configuration settings such as a database connection string for example, when we swap deployment slots in azure.
Deployment Slots - Default Behaviour
Let's say we have two deployment slots - staging and production. Staging slot points to the staging database and production slot points to the production database. Now, let's say we make a change to our application code. We deploy the new version of the application on the staging slot. We do all our testing. If we are happy with the results, we promote the build to production. The way we do this in azure is by swapping the two slots - staging to production and production to staging.
Upon swapping the slots, by default, along with the content, some application configuration settings like the database connection strings are also swapped. So this means, production slot is now pointing to the staging database and the staging slot is pointing to the production database.
This is definitely not the behaviour we want. Even after the swap, production slot should be pointing to the production database and staging slot should be pointing to the staging database.
Deployment Slot Setting
We want the database connection string to stick with the slot. We do not want it to be swapped during the swap operation. So to make the database connection string or any application configuration stick with the slot
- Navigate to either production or staging deployment slot
- Under
Settings
section, cick on theConfiguration
tab - Click on the
Edit
icon to edit the database connection string - Check the checkbox -
Deployment slot setting
With this setting in place, database connection strings are not swapped when the slots are swapped. So staging slot will always point to the staging database and production slot will always point to the production database.
© 2020 Pragimtech. All Rights Reserved.